/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.hsos.ai.swa.simplebookstore.entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;

/**
 *
 * @author rainer
 */
@Entity
public class StoreUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "user_id", nullable = false, length = 32)
    private String email;
    @NotNull
    @Column(name = "user_password", nullable = false, length = 128)
    private String password;
    @NotNull
    @Column(name = "user_group", nullable = false, length = 32)
    private String userGroup; 

    public StoreUser() {
    }

    public StoreUser(String email, String password) {
        this.email = email;
        this.password = password;
        this.userGroup = UserGroup.USER.name();
    }
    
    public StoreUser(String email, String password, UserGroup group) {
        this(email, password);
        this.userGroup = group.toString();
    } 

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUserGroup() {
        return userGroup;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 19 * hash + (this.email != null ? this.email.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final StoreUser other = (StoreUser) obj;
        if ((this.email == null) ? (other.email != null) : !this.email.equals(other.email)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "User{" + "email=" + email + ", password=" + password + ", userGroup=" + userGroup + '}';
    }
}
